home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
sound
/
sample20.zip
/
SAMPLER.DOC
< prev
next >
Wrap
Text File
|
1989-05-04
|
32KB
|
674 lines
Digital Sound Sample Playback and Manipulation System
-----------------------------------------------------
Version 2.0 Rowan McKenzie 28/3/89
(C) Copyright 1989 by Rowan McKenzie
You may copy these files or use the source code only
for non-profit purposes. Please contact me if you wish to use any
part of the package for commercial purposes.
I accept no responsibility for any injury or damage
caused by the use of any of these files.
SAMPLER/PWMSAMPL is true public domain. In other words, I ask for no
payment, registration fee, donations.... But please distribute these files
in the form you found them. Also I would appreciate acknowledgment in any
programs which use sections of my source code.
Introduction
------------
SAMPLER and PWMSAMPL are packages for playing and
manipulating digitised sound samples. SAMPLER expects an 8 bit D/A
converter to be available on a parallel printer port, while PWMSAMPL will
play sounds on the PC speaker using pulse width modulation. Of course the
quality of sound will be much better for the D/A version, however the PWM
version requires no additional hardware.
Support is provided for playing Pianoman .MUS files as songs using the
current sampled sound.
Hardware Requirements
---------------------
PWMSAMPL requires:
IBM XT/AT or close compatible
Hercules, CGA or EGA graphics card
SAMPLER requires in addition to the above:
An 8 bit D/A converter connected to a parallel
printer port
If the sampling feature is to be used, a fast 8
bit a/d converter is required (although the source
code will probably need to modified for your
setup).
Software Requirements
---------------------
MSDOS Ver 2.00 or later
Pianoman program and support files (PCblue Vol
216, PCsig Vol 279) if the song mode is to used
Background
----------
SAMPLER and PWMSAMPL were derived from an A/D, D/A sound sampling
system I wrote for an old CPM computer system.
The pulse width modulation code uses the 8253 timer chip in one shot
mode to drive the PC speaker with variable length pulses at a rate of
about 20kHz. Varying the pulse length produces the same result as varying
the voltage on a linearly controlled speaker. Unfortunately, the software
overhead for this could mean that slow XT systems may not be fast enough to
run PWMSAMPL. Also the sound volume is quite low (it's limited by the
difference between the shortest and longest pulses used, which is limited
by the sample rate, which is 20kHz for reasonable quality), so you will
need to listen in a quiet room, or else build a D/A converter for SAMPLER !
If you are interested in building a D/A converter to hear the much
better sound quality of SAMPLER, a standard R-2R resistor ladder (R ~ 10k)
into an amplifier of reasonably high input impedance (or low impedance via
a 100k resistor) will be quite adequate. Alternatively, an active circuit
using a chip such as the DAC0800 with its own power supply could be built.
The circuit shown below worked adequately for me.
D7 --- 20k ---+--- 200k -----> to amplifier
|
10k
|
D6 --- 20k ---+
|
10k
|
D5 --- 20k ---+
p |
r
i etc ...
n
t |
e 10k
r |
D0 --- 20k ---+
|
20k
|
=============== gnd
To utilise the sampling feature, a fast (at least 20kHz conversion
rate) A/D converter must be available. My converter was designed to begin a
conversion following a CPU access. As long as samples are taken at regular
intervals, this technique minimises I/O overheads. The converter is
addressed at the same location as the D/A converter to simplify the code.
If your converter doesn't meet these specifications (probably won't), then
the assembler code will require modification. SAMPLER is written in Turbo
Pascal Version 5, and the font and driver units can only be used with that
compiler.
Using SAMPLER / PWMSAMPL
------------------------
Version 2.0 of SAMPLER now uses mouse control rather than cumbersome
keyboard commands. It is therefore necessary to have an MSMOUSE (R) driver
installed before starting the program. Most mouse packages come with an
MSMOUSE compatible driver and either two or three button mouses will work
fine. If a mouse is unavailable, the cursor keys provide mouse emulation,
although this makes controlling SAMPLER more difficult.
If you are using a mouse, generally the left mouse button selects
objects while the right button cancels. The exception to this is for wave
drawing where the right button enables drawing. Dialog boxes which contain
a Continue prompt expect you to click on the box containing the Continue
prompt, although the right mouse button will have the same effect by
canceling the prompt. Also, pressing Enter in this situation will cause the
program to continue. You will notice that while a sound is being replayed
no mouse activity is possible. It was necessary to disable mouse interrupts
while producing sounds to avoid overloading the CPU. However, mouse control
can be temporarily restored during sounds by holding down the right shift
key.
If no mouse is available, the arrow keys provide coarse mouse control,
and the left shift key together with the arrow keys provides fine control.
The left button is emulated with the Alt key, and the right button is
replaced by the Ctrl key. For compatibility with my other mouse controlled
programs, the Caps lock key performs the same function as Ctrl, however
because a custom keyboard handler intercepts keyboard information, the caps
lock key can become confused. If the Caps Lock LED ever comes on, it may be
necessary to press Caps lock again before the program will continue.
When SAMPLER is first started by typing SAMPLER or PWMSAMPL,
information will be displayed about the default settings of the
configuration file. When the default sound file has loaded, a dialog box
containing all current settings will appear. Normally this is ignored by
clicking on the continue box (or canceling with the right button or Enter),
however, you may wish to alter an option before starting.
Once you are past the initial dialog box, a plot of the current
waveform will appear, together with several other objects. At the top of
the screen appears a group of menu headings. Clicking on a heading will
bring a sub-menu down. All SAMPLER functions now appear in the menu
structure, and no keyboard commands exist. The state of the more relevant
toggle-able functions and variables is given in a panel near the top of the
screen, all of which may be changed from the Settings box in the menu
(under Options). The current waveform appears in the center of the screen
with the current start, end and loop arrows above and below. At the lower
right is a collection of click-boxes which control the pitch of the sound
when replayed. The vertical arrows control the octave of the sound, while
the large and small left/right arrows alter the pitch within an octave. The
larger arrows provide coarse control. The Reset box will restore the
original default replay pitch, canceling the effect of other boxes. At the
lower right of the screen are a similar set of boxes which control the
period of the auto-timer. The auto-timer determines the rate of "auto sound
repea